package org.zetaframework.base.param;

import cn.hutool.core.io.file.FileNameUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;

/**
 * 获取导入Excel模板 参数
 *
 * @author gcc
 */
@Schema(description = "获取导入Excel模板参数")
public class ImportExcelTemplateParam {

    /** excel模板文件名 */
    @Schema(description = "excel模板文件名,不带扩展名", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "excel模板文件名不能为空")
    private String fileName;

    /** sheet名称 */
    @Schema(description = "sheet名称", example = "Sheet1", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private String sheetName = "Sheet1";

    /** 是否冻结表头 */
    @Schema(description = "是否冻结表头", example = "true", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Boolean freezeHeader = true;

    /** 是否添加时间戳后缀 */
    @Schema(description = "是否添加时间戳后缀", example = "true", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Boolean timestampSuffix = true;


    public String getFileName() {
        // 返回主文件名，如果文件名有扩展名，则返回扩展名之前的部分
        return FileNameUtil.mainName(fileName);
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }


    public String getSheetName() {
        // 处理sheetName的值为空字符串的情况
        return StrUtil.isNotBlank(sheetName) ? sheetName : "Sheet1";
    }

    public void setSheetName(String sheetName) {
        this.sheetName = sheetName;
    }

    public Boolean getFreezeHeader() {
        return freezeHeader;
    }

    public void setFreezeHeader(Boolean freezeHeader) {
        this.freezeHeader = freezeHeader;
    }

    public Boolean getTimestampSuffix() {
        return timestampSuffix;
    }

    public void setTimestampSuffix(Boolean timestampSuffix) {
        this.timestampSuffix = timestampSuffix;
    }
}
